import Cookies from 'js-cookie'
const env = import.meta.env

const cookies = {}

cookies.set = function (name = 'default', value = '', cookieSetting = { expires: 1 }) {
  Cookies.set(`taie-${env.VITE_APP_VERSION}-${name}`, value, cookieSetting)
}

cookies.get = function (name = 'default') {
  return Cookies.get(`taie-${env.VITE_APP_VERSION}-${name}`)
}

cookies.getAll = function () {
  return Cookies.get()
}

cookies.remove = function (name = 'default') {
  Cookies.remove(`taie-${env.VITE_APP_VERSION}-${name}`)
}

cookies.removeAll = function () {
  const jar = cookies.getAll()
  for (const i in jar) {
    Cookies.remove(i)
  }
}

export default cookies
